/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.hiof.voiceguide;

import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;
import android.net.Uri;
import com.hiof.Configuration;

/**
 *
 * @author manish
 */
public class AudioFilePlayer implements Speakable {

    private static AudioFilePlayer instance;
    private Notification notification;
    private NotificationManager mNotManager;
    private int fileId;

    private AudioFilePlayer() {
        notification = new Notification();
        mNotManager = (NotificationManager) Configuration.getInstance().getCurrentContext().getSystemService(Context.NOTIFICATION_SERVICE);
    }

    public static AudioFilePlayer getInstance() {
       if(instance == null){
          instance =  new AudioFilePlayer();
       }
       return  instance;
    }
    public void destroy(){
        if(instance != null){
            instance = null;
        }
    }

    public void speak() {
        notification.sound = Uri.parse(Configuration.RESOURCE_URL + fileId);
        mNotManager. notify(1, notification);
    }

    public void setArtifact(int artifactId) {
        this.fileId = artifactId;
    }

    public void setArtifact(String artifactId) {
        this.fileId = Integer.parseInt(artifactId);
    }

    @Override
    public void stop() {
    }
}
